package cn.itsource.basic.domain;

import cn.hutool.core.util.IdUtil;
import cn.hutool.crypto.digest.MD5;

public interface CreatePassword {
    public String getSalt();
    public void setSalt(String salt);

    public String getPassword();

    public void setPassword(String password);

    default void initMD5() {
        //设置盐值
        String salt = IdUtil.fastSimpleUUID();
        //记录盐值
        this.setSalt(salt);
        //加密密码;
        String pwd = MD5.create().setSalt(salt.getBytes()).digestHex(this.getPassword());
        //把密码设置进去
        this.setPassword(pwd);
    }
}
